package com.future.cb.common.bean;

import java.util.HashMap;

public class Record extends HashMap<String, Object> {
	/**
	 * 数据库记录类，主要用于多表查询时承载多个表的数据
	 */
	private static final long serialVersionUID = 1L;

	public String getStr(String column) {
		Object s = super.get(column.toUpperCase());
		return s != null ? s.toString() : null;
	}

	public Integer getInt(String column) {
		Number n = getNumber(column);
		return n != null ? n.intValue() : null;
	}

	public Long getLong(String column) {
		Number n = getNumber(column);
		return n != null ? n.longValue() : null;
	}

	public java.math.BigInteger getBigInteger(String column) {
		return (java.math.BigInteger) super.get(column.toUpperCase());
	}

	public java.util.Date getDate(String column) {
		return (java.util.Date) super.get(column.toUpperCase());
	}

	public java.sql.Time getTime(String column) {
		return (java.sql.Time) super.get(column.toUpperCase());
	}

	public java.sql.Timestamp getTimestamp(String column) {
		return (java.sql.Timestamp) super.get(column.toUpperCase());
	}

	public Double getDouble(String column) {
		Number n = getNumber(column);
		return n != null ? n.doubleValue() : null;
	}

	public Float getFloat(String column) {
		Number n = getNumber(column);
		return n != null ? n.floatValue() : null;
	}

	public Short getShort(String column) {
		Number n = getNumber(column);
		return n != null ? n.shortValue() : null;
	}

	public Byte getByte(String column) {
		Number n = getNumber(column);
		return n != null ? n.byteValue() : null;
	}

	public Boolean getBoolean(String column) {
		return (Boolean) super.get(column.toUpperCase());
	}

	public java.math.BigDecimal getBigDecimal(String column) {
		return (java.math.BigDecimal) super.get(column.toUpperCase());
	}

	public byte[] getBytes(String column) {
		return (byte[]) super.get(column.toUpperCase());
	}

	private Number getNumber(String column) {
		return (Number) super.get(column.toUpperCase());
	}
}
